package com.siyu.model.checkmodel;

import cn.hutool.log.LogFactory;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.stream.Collectors;

public class CheckModel {

    public static void calculatecheck() throws IOException {
        LogFactory.get().info("校正开始");
        String osName = System.getProperty("os.name").toLowerCase();
        String pythonCommand = osName.contains("win") ? "python" : "python3";
        Process process = new ProcessBuilder(pythonCommand, System.getProperty("user.dir")+"/siyu-model/src/main/resources/csv/check.py").start();
        String results = readProcessOutput(process.getInputStream());
        System.out.println(results);
        LogFactory.get().info("校正结束");
    }
    public static String readProcessOutput(InputStream inputStream) throws IOException {
        try (BufferedReader output = new BufferedReader(new InputStreamReader(inputStream))) {
            return output.lines().collect(Collectors.joining(""));
        }
    }
}
